(function () {
    var $self;
    return $self = Ext.define('Aurora.controller.Accounts', {
        extend: 'Ext.app.Controller',
        requires: ['Aurora.view.AccountsView'],
        config: {
            refs: {
                mainview: 'accountsMain'
            },
            control: {
                'accountsViewList': {
                    disclose: 'showDetails'
                },
                'button[action=back]': {
                    tap: 'goBack'
                }
            }
        },

        showDetails: function(list, record) {
            this.getMainview().push({
                xtype: 'accountDetailsView',
                id: 'accountDetails'
            });

            var details = Ext.getCmp('accountDetails');

            details.loadData(record);
        },

        goBack: function() {
            var details = Ext.getCmp('accountDetails');

            this.getMainview().pop(details);
        }
    });
})();